<template>
	<view class="main">
		<van-toast id="van-toast" />
		<tou_hand1 :handtitle="name"></tou_hand1>
		<view class="show">

			<view class="sone">
				<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
					<van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="loadMore">
						<van-cell v-for="(item, index) in showlist" :key="index">
							<view class="btap" @click="jumpbtn(item)">
								<view class="dbleft">
									<view class="dbtext">{{item.title}}</view>
								</view>
								<view class="dbright">
									<image src="https://qiniu.jxyutuo.com/yanqin/tabBarimg//dbright.png"></image>
								</view>
							</view>
						</van-cell>
					</van-list>
				</van-pull-refresh>

			</view>

		</view>
	</view>
</template>

<script>
	import tou_hand1 from '../../components/tou_hand2/tou_hand2.vue'

	export default {
		components: {
			tou_hand1
		},
		mounted() {

		},

		data() {
			return {
				name: '',
				type: '',
				loading: false,
				finished: false,
				refreshing: false,
				pageNum: 1, //页码
				pageSize: 10, //每页显示的条数
				showlist: [], //列表数据
			}
		},
		onLoad(options) {
			if (options.type == 1) {
				this.name = '使用流程'
			} else if (options.type == 2) {
				this.name = '常见问题'
			} else if (options.type == 3) {
				this.name = '用车常识'
			}
			this.type = options.type - 1

		},
		onShow() {
			this.showlist = []
			this.onRefresh();
		},
		methods: {
			// 获取用户管理的小区列表
			loadMore() {
				if (this.refreshing) {
					this.showlist = [];
					this.refreshing = false;
				}
				const that = this;
				let data = {
					type: this.type,
					pageNum: that.pageNum,
					pageSize: that.pageSize

				}
				that.loading = true;
				that.$base.request('help/list', 'GET', data)
					.then(res => {
						that.loading = false;
						if (res.data.rows && res.data.rows.length > 0) {
							that.showlist = that.showlist.concat(res.data.rows);
							that.pageNum += 1;
						} else {
							that.finished = true;
						}
					})
					.catch(err => {

					})
			},
			onRefresh() {
				// 清空列表数据
				this.finished = false;
				this.pageNum = 1
				// 重新加载数据
				// 将 loading 设置为 true，表示处于加载状态
				this.loading = true;
				this.loadMore();
			},
			jumpbtn(item) {
				if (item.url == '0') {
					uni.navigateTo({
						url: '../using_help_detail/using_help_detail?id=' + item.id
					})
				} else {
					window.location.href = item.url
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.main {
		width: 100%;
		height: 100vh;
		background-color: #F5F5F5;
		background-color:#fff;

		/deep/.van-cell {
			padding: 0upx;
		}

		/deep/.van-cell:not(:last-child)::after {
			border: 0upx solid #FFFFFF !important;
		}

		/deep/.van-list__finished-text {
			padding-top: 100upx;
			padding-bottom: 200upx;
			background-color: #F5F5F5;
		}

		/deep/.van-hairline--top-bottom::after {
			border-width: 0;
		}

		.show {
			width: 100%;

			.shand {
				width: 230upx;
				height: 230upx;
				margin: 90upx auto;

				image {
					width: 230upx;
					height: 230upx;
				}
			}

			.sone {
				width: 686upx;
				margin: 0 auto;
				background-color: #FFFFFF;
				// padding-top: 23upx;
				margin-bottom: 100upx;
				margin-top: 20upx;

				.btap {
					width: 100%;
					box-sizing: border-box;
					border-bottom: 1upx solid #ececec;
					display: flex;
					justify-content: space-between;
					padding: 21upx 19upx;
					// padding-bottom: 21upx;
					// margin-bottom: 21upx;
					align-items: center;

					.dbleft {
						box-sizing: border-box;
						display: flex;

						image {
							width: 29upx;
							height: 37upx;
							margin-top: 9upx;
						}

						.dbtext {
							box-sizing: border-box;
							padding-top: 8upx;
							margin-left: 22upx;
							font-size: 28upx;
							font-family: PingFang SC Medium, PingFang SC Medium-Medium;
							font-weight: 500;
							color: #333333;
						}

					}

					.dbright {
						box-sizing: border-box;
						display: flex;

						.dbphone {
							font-size: 24upx;
							font-family: PingFang SC Heavy, PingFang SC Heavy-Heavy;
							font-weight: 800;
							color: #4b98ed;
							margin-right: 28upx;
						}

						image {
							width: 19upx;
							height: 32upx;
						}

					}
				}
			}

		}

	}
</style>